global $IP;
$module = DatabaseSqlite::getFulltextSearchModule();
- $fts3tTable = $this->db->checkForEnabledSearch();
+ $searchIndexSql = (string)$this->db->selectField(
+ $this->db->addIdentifierQuotes( 'sqlite_master' ),
+ 'sql',
+ [ 'tbl_name' => $this->db->tableName( 'searchindex', 'raw' ) ],
+ __METHOD__
+ );
+ $fts3tTable = ( stristr( $searchIndexSql, 'fts' ) !== false );
+
if ( $fts3tTable && !$module ) {
$status->warning( 'config-sqlite-fts3-downgrade' );
$this->db->sourceFile( "$IP/maintenance/sqlite/archives/searchindex-no-fts.sql" );
return preg_match( '/^(:memory:$|file:(:memory:|[^?]+\?mode=memory(&|$)))/', $path );
}
- /**
- * Check if the searchindext table is FTS enabled.
- * @return bool False if not enabled.
- */
- public function checkForEnabledSearch() {
- if ( self::$fulltextEnabled === null ) {
- self::$fulltextEnabled = false;
- $table = $this->tableName( 'searchindex' );
- $res = $this->query(
- "SELECT sql FROM sqlite_master WHERE tbl_name = '$table'",
- __METHOD__,
- self::QUERY_IGNORE_DBO_TRX
- );
- if ( $res ) {
- $row = $res->fetchRow();
- self::$fulltextEnabled = stristr( $row['sql'], 'fts' ) !== false;
- }
- }
-
- return self::$fulltextEnabled;
- }
-
/**
* Returns version of currently supported SQLite fulltext search module or false if none present.
* @return string
*/
use MediaWiki\MediaWikiServices;
-use Wikimedia\Rdbms\DatabaseSqlite;
/**
* Search engine hook for SQLite
* @return bool
*/
private function fulltextSearchSupported() {
- // Avoid getConnectionRef() in order to get DatabaseSqlite specifically
- /** @var DatabaseSqlite $dbr */
- $dbr = $this->lb->getConnection( DB_REPLICA );
- try {
- return $dbr->checkForEnabledSearch();
- } finally {
- $this->lb->reuseConnection( $dbr );
- }
+ $dbr = $this->lb->getMaintenanceConnectionRef( DB_REPLICA );
+ $sql = (string)$dbr->selectField(
+ $dbr->addIdentifierQuotes( 'sqlite_master' ),
+ 'sql',
+ [ 'tbl_name' => $dbr->tableName( 'searchindex', 'raw' ) ],
+ __METHOD__
+ );
+
+ return ( stristr( $sql, 'fts' ) !== false );
}
/**